<template>
  <el-dropdown @command="handleCommand">
    <span class="el-dropdown-link">
      {{ name }}
      <el-icon class="el-icon--right">
        <arrow-down/>
      </el-icon>
    </span>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item v-for="(item,index) in itemList" :key="index" :command="item">{{ item }}</el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script lang="ts" setup>
import {} from 'vue'

defineProps({
  name: {
    type: String,
    default: ''
  },
  itemList: {
    type: Array,
    default: []
  }
})

let emits = defineEmits<{
  (event: 'handleCommand', command: string): void
}>();
let handleCommand = (command: string) => {
  emits('handleCommand', command)
}
</script>

<style scoped lang='less'>

</style>
